import { List, NavBar } from "antd-mobile";
//@ts-ignore
import { useNavigate } from "umi";
import React, { useEffect, useState } from "react";
import axios from "axios";

function index() {
  const navigate = useNavigate();
  const back = () => navigate("/user");
  //   已支付列表
  const [payok, setPayOk] = useState<any>();
  //   查询全部订单
  const payOk = async () => {
    const res = await axios({
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        token: localStorage.getItem("token"),
      },
      method: "get",
      url: `http://43.139.124.13:8888/order/queryPayOrder`,
    });
    console.log(res);
    setPayOk(res.data.data);
  };
  useEffect(() => {
    payOk();
  }, []);

  return (
    <>
      <NavBar onBack={back}>已支付列表</NavBar>
      {payok?.map((item: any) => (
        <List key={item.orderNo}>
          <List.Item
            title={`订单编号:${item.orderNo} `}
            description={`地址：${item.linkAddress}`}
            clickable
          >
            {`总价${item.totalPrice}`}
            <br />
            <span style={{ fontSize: 8 }}>手机号：{item.linkPhone}</span>
          </List.Item>
        </List>
      ))}
    </>
  );
}

export default index;
